#include "stdafx.h"
#include "Input.h"

#include "Log.h"
#include "Exception.h"
#include "ErrorHandlers.h"
#include "MemUtils.h"

namespace Cvekas {

Input::Input(HWND handle) 
	: 
win_handle(handle)
{
	LOG("Input initialized");
}

Input::~Input()
{
	LOG("Input destroyed");
}

KeyboardPtr Input::getKeyboard()
{
	if(!keyboard)
	{
		LOG("Creating Keyboard...");
		keyboard = KeyboardPtr(new Keyboard());
	}
	return keyboard;
}

MousePtr Input::getMouse()
{
	if(!mouse)
	{
		LOG("Creating Mouse...");
		mouse = MousePtr(new Mouse());
	}
	return mouse;
}

bool Input::process(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	bool keyboard_result = false;
	bool mouse_result = false;

	if(keyboard)
		keyboard_result = keyboard->process(hWnd, message, wParam, lParam);
	if(keyboard_result)
		return true;

	if(mouse)
		mouse_result = mouse->process(hWnd, message, wParam, lParam);
	if(mouse_result)
		return true;

	return false;
}

} // namespace